package br.ufpe.cin.analysis.plugin.models;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.bind.JAXBException;

import org.jfree.data.category.DefaultCategoryDataset;

import br.ufpe.cin.analysis.plugin.entities.Activity;
import br.ufpe.cin.analysis.plugin.entities.Metric;
import br.ufpe.cin.analysis.plugin.entities.Process;

public class BarDataset extends ChartDataset<DefaultCategoryDataset> {


	public BarDataset(String xmlFileName) throws JAXBException, IOException
	{
		super(xmlFileName);
	}

	public BarDataset(Process process) {
		super(process);
	}
	
	public BarDataset(Process process, String xmlFile)
	{
		super(process,xmlFile);
	}

	public BarDataset()
	{
		super();
	}

	@Override
	public void makeJFreeChartDataset() {

		this.setJFreeChartDataset( new DefaultCategoryDataset() );

		for( Activity ac : this.getProcess().getActivities() )
		{
			if(ac.getSelected()){
				for( Metric m : ac.getMetrics())
				{
					if(m.getSelected()) this.getJFreeChartDataset().addValue(m.getValue(), ac.getName(), m.getName());				
				}
			}
		}


	}





}
